package persistencia;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import modelo.CursoExtraCurricular;
import modelo.Endereco;
import modelo.Experiencia;
import modelo.Formacao;
import modelo.Idioma;
import modelo.Profissional;


@SuppressWarnings("unchecked")
public class DAOProfissional {
    
    private Connection conexao;
    
    private void obterConexao(){
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conexao = DriverManager.getConnection("jdbc:mysql://localhost/sirp", "root", "123");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    
    private void liberarConexao(){
        try {
            conexao.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    
    private void inserirEndereco(Endereco endereco, Profissional profissional) throws SQLException{
        if (endereco != null){
            PreparedStatement pstat = conexao.prepareStatement("INSERT INTO Endereco (rua, numero, complemento, bairro, cidade, estado, pais, cep, profissional_fk) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
            pstat.setString(1, endereco.getRua());
            pstat.setString(2, endereco.getNumero());
            pstat.setString(3, endereco.getComplemento());
            pstat.setString(4, endereco.getBairro());
            pstat.setString(5, endereco.getCidade());
            pstat.setString(6, endereco.getPais());
            pstat.setString(7, endereco.getCEP());
            pstat.setString(8, profissional.getEmail());
            pstat.executeUpdate();
        }
       
    }
    
    private void alterarEndereco(Endereco endereco, Profissional profissional) throws SQLException{
        if (endereco != null){
            PreparedStatement pstat = conexao.prepareStatement("UPDATE Endereco SET rua = ?, numero = ?, complemento = ?, bairro = ?, cidade = ?, estado = ?, pais = ?, cep = ?, profissional_fk = ? WHERE id = ?");
            pstat.setString(1, endereco.getRua());
            pstat.setString(2, endereco.getNumero());
            pstat.setString(3, endereco.getComplemento());
            pstat.setString(4, endereco.getBairro());
            pstat.setString(5, endereco.getCidade());
            pstat.setString(6, endereco.getPais());
            pstat.setString(7, endereco.getCEP());
            pstat.setString(8, profissional.getEmail());
            pstat.executeUpdate();
        }
        
    }
    
    @SuppressWarnings("unused")
	private void excluirEndereco(Endereco endereco, Profissional profissional) throws SQLException{

        try {
            Statement stat = conexao.createStatement();
            stat.executeUpdate("DELETE FROM Endereco WHERE id = '" + endereco.getId() + "' ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        
    }
        
    private void inserirFormacao(Formacao formacao, Profissional profissional) throws SQLException{
        if (formacao != null){
            PreparedStatement pstat = conexao.prepareStatement("INSERT INTO Formacao (instituicao, graduacao, dataInicio, previsaoConclusao, informacoesAdicionais, profissional_fk) VALUES (?, ?, ?, ?, ?)");
            pstat.setString(1, formacao.getInstituicao());
            pstat.setString(2, formacao.getGraduacao());
            pstat.setString(3, formacao.getDataInicio());
            pstat.setString(4, formacao.getPrevisaoConclusao());
            pstat.setString(5, formacao.getInformacoesAdicionais());
            pstat.executeUpdate();
        }
       
    }
    
    private void alterarFormacao(Formacao formacao, Profissional profissional) throws SQLException{
        if (formacao != null){
            PreparedStatement pstat = conexao.prepareStatement("UPDATE Formacao SET rua = ?, instituicao = ?, graduacao = ?, dataInicio = ?, previsaoConclusao = ?, informacoesAdicionais = ?, profissional_fk = ? WHERE id = ?");
            pstat.setString(1, formacao.getInstituicao());
            pstat.setString(2, formacao.getGraduacao());
            pstat.setString(3, formacao.getDataInicio());
            pstat.setString(4, formacao.getPrevisaoConclusao());
            pstat.setString(5, formacao.getInformacoesAdicionais());
            pstat.executeUpdate();
        }
        
    }
    
    @SuppressWarnings("unused")
	private void excluirFormacao(Formacao formacao, Profissional profissional) throws SQLException{
        
        try {
            Statement stat = conexao.createStatement();
            stat.executeUpdate("DELETE FROM Formacao WHERE id = '" + formacao.getId() + "' ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        
    }
      
    private void inserirIdioma(Idioma idioma, Profissional profissional) throws SQLException{
        if (idioma != null){
            PreparedStatement pstat = conexao.prepareStatement("INSERT INTO Idioma (idioma, nivel, profissional_fk) VALUES (?, ?)");
            pstat.setString(1, idioma.getIdioma());
            pstat.setString(2, idioma.getNivel());
            pstat.executeUpdate();
            
        }
       
    }
    
    private void alterarIdioma(Idioma idioma, Profissional profissional) throws SQLException{
        if (idioma != null){
            PreparedStatement pstat = conexao.prepareStatement("UPDATE Idioma SET idioma = ?, nivel = ?, profissional_fk = ? WHERE id = ?");
            pstat.setString(1, idioma.getIdioma());
            pstat.setString(2, idioma.getNivel());
            pstat.executeUpdate();
         
        }
        
    }
    
    @SuppressWarnings("unused")
	private void excluirIdioma(Idioma idioma, Profissional profissional) throws SQLException{
        
        try {
            Statement stat = conexao.createStatement();
            stat.executeUpdate("DELETE FROM Idioma WHERE id = '" + idioma.getId() + "' ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        
    }
       
    private void inserirCursoExtraCurricular(CursoExtraCurricular cursoExtraCurricular, Profissional profissional) throws SQLException{
        if (cursoExtraCurricular != null){
            PreparedStatement pstat = conexao.prepareStatement("INSERT INTO CursoExtraCurricular (instituicao, curso, duracao, situacao, profissional_fk) VALUES (?, ?, ? ,?, ?)");
            pstat.setString(1, cursoExtraCurricular.getInstituicao());
            pstat.setString(2, cursoExtraCurricular.getCurso());
            pstat.setString(3, cursoExtraCurricular.getDuracao());
            pstat.setString(4, cursoExtraCurricular.getSituacao());
            pstat.executeUpdate();
            
        }
       
    }
    
    private void alterarCursoExtraCurricular(CursoExtraCurricular cursoExtraCurricular, Profissional profissional) throws SQLException{
        if (cursoExtraCurricular != null){
            PreparedStatement pstat = conexao.prepareStatement("UPDATE CursoExtraCurricular SET instituicao = ?, curso = ?, duracao = ?, situacao = ?, profissional_fk = ? WHERE id = ?");
            pstat.setString(1, cursoExtraCurricular.getInstituicao());
            pstat.setString(2, cursoExtraCurricular.getCurso());
            pstat.setString(3, cursoExtraCurricular.getDuracao());
            pstat.setString(4, cursoExtraCurricular.getSituacao());
            pstat.executeUpdate();
         
        }
       
    }
    
    @SuppressWarnings("unused")
	private void excluirCursoExtraCurricular(CursoExtraCurricular cursoExtraCurricular, Profissional profissional) throws SQLException{
        
        try {
            Statement stat = conexao.createStatement();
            stat.executeUpdate("DELETE FROM CursoExtraCurricular WHERE id = '" + cursoExtraCurricular.getId() + "' ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        
    }
        
    private void inserirExperiencia(Experiencia experiencia, Profissional profissional) throws SQLException{
        if (experiencia != null){
            PreparedStatement pstat = conexao.prepareStatement("INSERT INTO Experiencia (empresa, cargo, dataAdmissao, dataDemissao, atividades, profissional_fk) VALUES (?, ?, ? ,?, ?, ?)");
            pstat.setString(1, experiencia.getEmpresa());
            pstat.setString(2, experiencia.getCargo());
            pstat.setString(3, experiencia.getDataAdmissao());
            pstat.setString(4, experiencia.getDataDemissao());
            pstat.setString(5, experiencia.getAtividades());
            pstat.executeUpdate();
            
        }
        
    }
    
    private void alterarExperiencia(Experiencia experiencia, Profissional profissional) throws SQLException{
        if (experiencia != null){
            PreparedStatement pstat = conexao.prepareStatement("UPDATE Experiencia SET empresa = ?, cargo = ?, dataAdmissao = ?, dataDemissao = ?, atividades, profissional_fk = ? WHERE id = ?");
            pstat.setString(1, experiencia.getEmpresa());
            pstat.setString(2, experiencia.getCargo());
            pstat.setString(3, experiencia.getDataAdmissao());
            pstat.setString(4, experiencia.getDataDemissao());
            pstat.setString(5, experiencia.getAtividades());
            pstat.executeUpdate();
         
        }
        
    }
    
    @SuppressWarnings("unused")
	private void excluirExperiencia(Experiencia experiencia, Profissional profissional) throws SQLException{
        
        try {
            Statement stat = conexao.createStatement();
            stat.executeUpdate("DELETE FROM Experiencia WHERE id = '" + experiencia.getId() + "' ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        
    }
     
    
    public void inserir(Profissional profissional){
        obterConexao();
        try {
            PreparedStatement pstat = conexao.prepareStatement("INSERT INTO Profissional (nome, sobrenome, sexo, idade, dataNascimento, estadoCivil, profissao, estudante, fumante, filhos, moro, hobby, descricao, telefoneCelular, telefoneComercial, telefoneResidencial, webSite, email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
            pstat.setString(1, profissional.getNome());
            pstat.setString(2, profissional.getSobrenome());
            pstat.setString(3, profissional.getSexo());
            pstat.setInt(4, profissional.getIdade());
            pstat.setDate(5, new java.sql.Date(profissional.getDataNascimento().getTime()));  
            pstat.setString(6, profissional.getEstadoCivil());
            pstat.setString(7, profissional.getProfissao());
            pstat.setBoolean(8, profissional.isEstudante());
            pstat.setBoolean(9, profissional.isFumante());
            pstat.setBoolean(10, profissional.isFilhos());
            pstat.setString(11, profissional.getMoro());
            pstat.setString(12, profissional.getHobby());
            pstat.setString(13, profissional.getDescricao());
            pstat.setString(14, profissional.getTelefoneCelular());
            pstat.setString(15, profissional.getTelefoneResidencial());
            pstat.setString(16, profissional.getTelefoneComercial());
            pstat.setString(17, profissional.getWebSite());
            pstat.setString(18, profissional.getEmail());
            
            pstat.executeUpdate();
            //inserir endereco, formacao, idioma, cursoExtraCurricular, experiencia, contato, grupo, mesnsagem
            
            if (profissional.getEnderecos() != null){
                Endereco[] e = profissional.getEnderecos();
                for (int i = 0; i < e.length; i++){
                    inserirEndereco(e[i], profissional);
                }
            }
            
            if (profissional.getFormacao() != null){
                Formacao[] f = profissional.getFormacao();
                for (int i = 0; i < f.length; i++){
                    inserirFormacao(f[i], profissional);
                }
            }
            
            if (profissional.getIdioma() != null){
                Idioma[] idm = profissional.getIdioma();
                for (int i = 0; i < idm.length; i++){
                    inserirIdioma(idm[i], profissional);
                }
            }
            
            if (profissional.getCursoExtraCurricular() != null){
                CursoExtraCurricular[] curso = profissional.getCursoExtraCurricular();
                for (int i = 0; i < curso.length; i++){
                    inserirCursoExtraCurricular(curso[i], profissional);
                }
            }
            
            if (profissional.getExperiencia() != null){
                Experiencia[] exp = profissional.getExperiencia();
                for (int i = 0; i < exp.length; i++){
                    inserirExperiencia(exp[i], profissional);
                }
            }
            
                  
        } catch (SQLException e) {
            e.printStackTrace();
        }
        liberarConexao();
    }
    
    public void atualizar(Profissional profissional){
        obterConexao();
        try {
        	 PreparedStatement stat = conexao.prepareStatement("UPDATE Profissional SET nome = ?, sobrenome = ?, sexo = ?, idade = ?, dataNascimento = ?, estadoCivil = ?, profissao = ?, estudante = ?, fumante = ?, filhos = ?, moro = ?, hobby = ?, descricao = ?, telefoneCelular = ?, telefoneComercial = ?, telefoneResidencial = ?, webSite = ? WHERE email = ? ");
             
             stat.setString(1, profissional.getNome());
             stat.setString(2, profissional.getSobrenome());
             stat.setString(3, profissional.getSexo());
             stat.setInt(4, profissional.getIdade());
             stat.setDate(5, new java.sql.Date(profissional.getDataNascimento().getTime())); 
             stat.setString(6, profissional.getEstadoCivil());
             stat.setString(7, profissional.getProfissao());
             stat.setBoolean(8, profissional.isEstudante());
             stat.setString(9, profissional.getHobby());
             stat.setBoolean(10, profissional.isFumante());
             stat.setBoolean(11, profissional.isFilhos());
             stat.setString(12, profissional.getMoro());
             stat.setString(13, profissional.getDescricao());
             stat.setString(14, profissional.getTelefoneCelular());
             stat.setString(15, profissional.getTelefoneResidencial());
             stat.setString(16, profissional.getTelefoneComercial());
             stat.setString(17, profissional.getWebSite());
             stat.setString(18, profissional.getEmail());
             stat.executeUpdate();
            
             stat = conexao.prepareStatement("UPDATE Endereco SET profissional_fk = '' WHERE profissional_fk = ? ");
             stat.setString(1, profissional.getEmail());
             stat.executeUpdate();
             
             if (profissional.getEnderecos()!= null){
                Endereco[] e = profissional.getEnderecos();
                for (int i = 0; i < e.length; i++){
                    if (e[i].getId() != 0){
                        alterarEndereco(e[i], profissional);
                    } else {
                        inserirEndereco(e[i], profissional);
                    }
                }
            }
            
            stat = conexao.prepareStatement("UPDATE Formacao SET profissional_fk = '' WHERE profissional_fk = ? ");
            stat.setString(1, profissional.getEmail());
            stat.executeUpdate();

            if (profissional.getFormacao()!= null){
                Formacao[] f = profissional.getFormacao();
                for (int i = 0; i < f.length; i++){
                    if (f[i].getId() != 0){
                        alterarFormacao(f[i], profissional);
                    } else {
                        inserirFormacao(f[i], profissional);
                    }
                }
            }
            
            stat = conexao.prepareStatement("UPDATE Idioma SET profissional_fk = '' WHERE profissional_fk = ? ");
            stat.setString(1, profissional.getEmail());
            stat.executeUpdate();

            if (profissional.getIdioma()!= null){
                Idioma[] idm = profissional.getIdioma();
                for (int i = 0; i < idm.length; i++){
                    if (idm[i].getId() != 0){
                        alterarIdioma(idm[i], profissional);
                    } else {
                        inserirIdioma(idm[i], profissional);
                    }
                }
            }
            
            stat = conexao.prepareStatement("UPDATE CursoExtraCurricular SET profissional_fk = '' WHERE profissional_fk = ? ");
            stat.setString(1, profissional.getEmail());
            stat.executeUpdate();

            if (profissional.getCursoExtraCurricular()!= null){
                CursoExtraCurricular[] curso = profissional.getCursoExtraCurricular();
                for (int i = 0; i < curso.length; i++){
                    if (curso[i].getId() != 0){
                        alterarCursoExtraCurricular(curso[i], profissional);
                    } else {
                        inserirCursoExtraCurricular(curso[i], profissional);
                    }
                }
            }
            
            stat = conexao.prepareStatement("UPDATE Experiencia SET profissional_fk = '' WHERE profissional_fk = ? ");
            stat.setString(1, profissional.getEmail());
            stat.executeUpdate();

            if (profissional.getExperiencia()!= null){
                Experiencia[] exp = profissional.getExperiencia();
                for (int i = 0; i < exp.length; i++){
                    if (exp[i].getId() != 0){
                        alterarExperiencia(exp[i], profissional);
                    } else {
                        inserirExperiencia(exp[i], profissional);
                    }
                }
            }
                                       
        } catch (SQLException e) {
            e.printStackTrace();
        }
        liberarConexao();
    }
    
    public void excluir(Profissional profissional){
        obterConexao();
        try {
            Statement stat = conexao.createStatement();
            stat.executeUpdate("DELETE FROM Profissional WHERE email = '" + profissional.getEmail() + "' ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        liberarConexao();
    }
    
    public Profissional buscarProfissional(String email){
        obterConexao();
        try {
            PreparedStatement stat = conexao.prepareStatement("SELECT * FROM Profissional WHERE email = ?");
            stat.setString(1, email);
            ResultSet set = stat.executeQuery();
                                                   
            if (set.next()){
            	Profissional profissional = new Profissional();
            	
            	profissional.setNome(set.getString("nome"));
            	profissional.setSobrenome(set.getString("sobrenome"));
            	profissional.setSexo(set.getString("sexo"));
            	profissional.setIdade(set.getInt("idade"));
            	profissional.setDataNascimento(set.getDate("dataNascimento"));
            	profissional.setEstadoCivil(set.getString("estadoCivil"));
            	profissional.setProfissao(set.getString("profissao"));
            	profissional.setEstudante(set.getBoolean("estudante"));
            	profissional.setFumante(set.getBoolean("fumante"));
            	profissional.setFilhos(set.getBoolean("filhos"));
            	profissional.setMoro(set.getString("moro"));
            	profissional.setHobby(set.getString("hobby"));
            	profissional.setDescricao(set.getString("descricao"));
            	profissional.setTelefoneCelular(set.getString("telefoneCelular"));
            	profissional.setTelefoneResidencial(set.getString("telefoneResidencial"));
            	profissional.setTelefoneComercial(set.getString("telefoneComercial"));
            	profissional.setWebSite(set.getString("webSite"));
            	profissional.setEmail(set.getString("email"));
            	
                stat = conexao.prepareStatement("SELECT count(*) FROM Endereco WHERE profissional_fk = ?");
                stat.setString(1, email);
                set = stat.executeQuery();
                
                if (set.next()){
                    int totalEnderecos = set.getInt(1);
                    if (totalEnderecos > 0){
                    	stat = conexao.prepareStatement("SELECT id = ?, rua = ?, numero = ?, complemento = ?, bairro = ?, cidade = ?, estado = ?, pais = ?, cep = ?, profissional_fk = ?");
                    	stat.setString(1, email);
                    	set = stat.executeQuery();
                    	Endereco[] enderecos = new Endereco[totalEnderecos];
                    	for (int i = 0; i < totalEnderecos; i++){
                    		set.next();
                    		enderecos[i] = new Endereco();
                    		enderecos[i].setId(set.getInt("id"));
                    		enderecos[i].setRua(set.getString("rua"));
                    		enderecos[i].setNumero(set.getString("numero"));
                    		enderecos[i].setComplemento(set.getString("complemento"));
                    		enderecos[i].setBairro(set.getString("bairro"));
                    		enderecos[i].setCidade(set.getString("cidade"));
                    		enderecos[i].setEstado(set.getString("estado"));
                    		enderecos[i].setPais(set.getString("pais"));
                    		enderecos[i].setCEP(set.getString("cep"));
                    			
                    	}
                    		profissional.setEnderecos(enderecos);
                    }
                }
                                      
                if (set.next()){
                	int totalFormacoes = set.getInt(1);
                	if (totalFormacoes  > 0){
                		stat = conexao.prepareStatement("SELECT id = ?, instituicao = ?, graduacao = ?, dataInicio = ?, previsaoConclusao = ?, informacoesAdicionais = ?, profissional_fk = ?");
                		stat.setString(1, email);
                		set = stat.executeQuery();
                		Formacao [] formacoes  = new Formacao[totalFormacoes];
                		for (int i = 0; i < totalFormacoes ; i++){
                			set.next();
                			formacoes[i] = new Formacao();
                			formacoes[i].setId(set.getInt("id"));
                			formacoes[i].setInstituicao(set.getString("instituicao"));
                			formacoes[i].setGraduacao(set.getString("graduacao"));
                			formacoes[i].setDataInicio(set.getString("dataInicio"));
                			formacoes[i].setPrevisaoConclusao(set.getString("previsaoConclusao"));
                			formacoes[i].setInformacoesAdicionais(set.getString("informacoesAdicionais"));
                			            			
                		}
                		profissional.setFormacao(formacoes);
                	}
                }
              
                if (set.next()){
                	int totalIdiomas = set.getInt(1);
                	if (totalIdiomas > 0){
                		stat = conexao.prepareStatement("SELECT id = ?, idioma = ?, nivel = ?, profissional_fk = ?");
                		stat.setString(1, email);
                		set = stat.executeQuery();
                		Idioma[] idiomas = new Idioma[totalIdiomas];
                		for (int i = 0; i < totalIdiomas; i++){
                			set.next();
                			idiomas[i] = new Idioma();
                			idiomas[i].setId(set.getInt("id"));
                			idiomas[i].setIdioma(set.getString("idioma"));
                			idiomas[i].setNivel(set.getString("nivel"));
            			
            			
            		}
            		profissional.setIdioma(idiomas);
                	}
                }
          
                if (set.next()){
                	int totalCursoExtraCurricular = set.getInt(1);
                	if (totalCursoExtraCurricular > 0){
                		stat = conexao.prepareStatement("SELECT id = ?, instituicao = ?, curso = ?, duracao = ?, situacao = ?, profissional_fk = ?");
                		stat.setString(1, email);
                		set = stat.executeQuery();
                		CursoExtraCurricular[] cursoExtraCurricular = new CursoExtraCurricular[totalCursoExtraCurricular];
                		for (int i = 0; i < totalCursoExtraCurricular; i++){
                			set.next();
                			cursoExtraCurricular[i] = new CursoExtraCurricular();
                			cursoExtraCurricular[i].setId(set.getInt("id"));
                			cursoExtraCurricular[i].setInstituicao(set.getString("instituicao"));
                			cursoExtraCurricular[i].setCurso(set.getString("curso"));
                			cursoExtraCurricular[i].setDuracao(set.getString("duracao"));
                			cursoExtraCurricular[i].setSituacao(set.getString("situacao"));
            			        			
            		}
            		profissional.setCursoExtraCurricular(cursoExtraCurricular);
                	}
                }
            
                if (set.next()){
                	int totalExperiencias = set.getInt(1);
                	if (totalExperiencias > 0){
                		stat = conexao.prepareStatement("SELECT id = ?, empresa = ?, cargo = ?, dataAdmissao = ?, dataDemissao = ?, atividades = ?, profissional_fk = ?");
                		stat.setString(1, email);
                		set = stat.executeQuery();
                		Experiencia[] experiencias = new Experiencia[totalExperiencias];
                		for (int i = 0; i < totalExperiencias; i++){
                			set.next();
                			experiencias[i] = new Experiencia();
                			experiencias[i].setId(set.getInt("id"));
                			experiencias[i].setEmpresa(set.getString("empresa"));
                			experiencias[i].setCargo(set.getString("cargo"));
                			experiencias[i].setDataAdmissao(set.getString("dataAdmissao"));
                			experiencias[i].setDataDemissao(set.getString("dataDemissao"));
                			experiencias[i].setAtividades(set.getString("atividades"));
            			        			
                		}
                			profissional.setExperiencia(experiencias);
                		}
                }
                   
                return profissional;
            }
                       
            } catch (SQLException e) {
                e.printStackTrace();
            }
            liberarConexao();
            return null;
    }


    
	public List listarGridProfissional(){
        obterConexao();
        List listProfissionais = new ArrayList();
        try {
            Statement stat;
            stat = conexao.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            ResultSet set = stat.executeQuery("SELECT * FROM Profissional");
              
            while (set.next()){
            	
            	HashMap hashmapProfissionais = new HashMap();
            	hashmapProfissionais.put("nome", set.getString("nome"));
            	hashmapProfissionais.put("sobrenome", set.getString("sobrenome"));
            	hashmapProfissionais.put("sexo", set.getString("sexo"));
            	hashmapProfissionais.put("idade", set.getString("idade"));
            	hashmapProfissionais.put("profissao", set.getString("profissao"));
            	listProfissionais.add(hashmapProfissionais);            	
            }
                                   
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return listProfissionais;
            
	}
}